//part1:C06:ex6.4.cpp
#include <iostream>

int fact(int val) {
    if(val < 0) {
        return -1;
    }

    int ret = 1;
    for (int i = 1; i != val + 1; ++i) {
        ret *= i;
    }

    return ret;
}

int main(void) {
    using namespace std;
    int num;
    cout << "Enter a integer for factorial:" << endl;
    cin >> num;
    cout << num << " factorial is : " << fact(num) << endl;

    return 0;
}
